package com.hqd.jjvm.classformat.constantpool;

import com.hqd.jjvm.classformat.ClassFile;
import com.hqd.jjvm.util.HexStrTransformUtil;

public class ConstantLongInfo extends ConstantPool {
	private Integer highBytes;
	private Integer lowBytes;

	public ConstantLongInfo(ConstantInfoType tag, ClassFile classFile) {
		super(tag, classFile);
		this.highBytes = HexStrTransformUtil.parseHexToInt(classFile.readU4());
		this.lowBytes = HexStrTransformUtil.parseHexToInt(classFile.readU4());
	}

	@Override
	public Long getVal() {
		long low = lowBytes & 0x00000000ffffffffL;
		long high = (highBytes & 0x000000ffffffffL) << 32;
		return high | low;
	}
}
